package com.eight.cloud.mybatisflex.factory;

import com.eight.cloud.core.global.model.BaseUser;
import com.eight.cloud.core.utils.supply.UserContext;
import com.mybatisflex.core.tenant.TenantFactory;

import java.util.Objects;

/**
 * @ClassName: MfTenantFactory
 * @Author: TXC
 * @Date: 2025-09-15 17:57
 **/
public class MfTenantFactory implements TenantFactory {
    @Override
    public Object[] getTenantIds(String tableName) {
        return this.getTenantIds();
    }

    @Override
    public Object[] getTenantIds() {
        BaseUser baseUser = UserContext.getUser();
        if (Objects.isNull(baseUser)) {
            return null;
        }
        String tenantId = baseUser.getTenantId();
        return new String[]{tenantId};
    }
}
